package com.dayaokeji.rhythmschoolstudent.view

import android.annotation.SuppressLint
import android.content.Context
import android.support.v4.view.ViewPager
import android.util.AttributeSet
import android.view.MotionEvent

class NoScrollViewPager(cxt: Context,attrs: AttributeSet) : ViewPager(cxt,attrs) {

    private var isScroll = false

    override fun dispatchTouchEvent(ev: MotionEvent?): Boolean {
        return super.dispatchTouchEvent(ev)
    }

    override fun onInterceptTouchEvent(ev: MotionEvent?): Boolean {

        return if (isScroll) {
            super.onInterceptTouchEvent(ev)
        }else{
            false
        }
    }


    @SuppressLint("ClickableViewAccessibility")
    override fun onTouchEvent(ev: MotionEvent?): Boolean {

        return if (isScroll) {
            super.onTouchEvent(ev)
        }else{
            true
        }
    }
}